
    if($.cookie('Authorization')!==null && localStorage.getItem('realname') !== null && localStorage.getItem('fromWeb') === '1') {
        localStorage.setItem('fromWeb', '0')
        $.cookie('AuthorizationAdmin', $.cookie('Authorization'), { expires: 7 })
        localStorage.setItem("adminName", localStorage.getItem('realname'));
        window.location.href = host_url + "admin/accountList.html";
    } else {
        localStorage.removeItem('adminName')
        $(document).ready(function(){
            $("#uyzm_img").attr('src', service_url + "/servlet/validateCodeServlet");
        
            // 点击登录
            $('#loginBtn').click(function() {
                var tel = $('#tel').val()
                var password = $('#password').val()
                var code = $('#code').val()
                $('.msg-text').text('')
                if (tel === '') {
                    $('.msg-text').text('登录手机号不能为空')
                    $('#tel').focus()
                    return
                }
                if (password === '') {
                    $('.msg-text').text('登录密码不能为空')
                    $('#password').focus()
                    return
                }
                if (code === '') {
                    $('.msg-text').text('验证码不能为空')
                    $('#code').focus()
                    return
                }
                onValidateBlurHandler()
            });
        })
    }
    



// 更换验证码
function changeImg(target) {
    $(target).attr("src", service_url + "/servlet/validateCodeServlet?" + new Date().getTime());
}
// 回车登录
function keyLogin(){
    if (event.keyCode==13)  $("#loginBtn").click(); //调用登录按钮的登录事件
}
// 校验验证码
function onValidateBlurHandler(){
    $.ajax({
        url: service_url + '/servlet/validateCodeServlet?validateCode=' + $("#code").val(),
        type: 'GET', //请求方式
        aysc: true,
        dataType: 'jsonp',
        jsonp: "callback",
        crossDomain: true,
        xhrFields: {
            withCredentials: true
        },
        contentType: 'application/json',
        jsonpCallback: "callback", 
        success: function(data) {
            console.log(data)
            // 通过
            if (data.valid) {
                var jsonstr = $("#tel").val() + ',' + $("#password").val();
                var base64 = new Base64()
                $.ajax({
                    url: service_url + '/a/zkLogin?watvalue=' + base64.encode(jsonstr),
                    type: 'GET',
                    xhrFields: {
                        withCredentials: true
                    },
                    crossDomain: true,
                    contentType: 'application/json',
                    dataType: 'jsonp',
                    jsonpCallback:"success_jsonpCallback",  
                    processData: false, // 告诉jQuery不要去处理发送的数据
                    success: function(data) {
                        if(data.status == '00') {
                            $.cookie('AuthorizationAdmin', data.token, { expires: 7 })
                            localStorage.setItem("adminName", data.user.realname);
                            /*判断有无设置记录 bootpage为true，则跳首页*/
                            window.location.href = host_url + "admin/accountList.html";
                        } else {
                            $('.msg-text').text('账号或者密码错误')
                        }
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        console.log(XMLHttpRequest, textStatus, errorThrown)
                    }
                })
            } else {// 未通过
                $('.msg-text').text('验证码错误')
                $('#code').focus()
            }
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            console.log(XMLHttpRequest, textStatus, errorThrown)
        }
    })

}